package cn.itcast.dao;


import cn.itcast.Product;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;



public interface ProductDao {

    /**
     * 查询所有
     * @return
     */
    @Select("select * from product")
    public List<Product> findAll();


    /**
     * 添加产品
     * @param product
     */
    @Insert(" insert into product" +
            "(productNum,productName,cityName,departureTime,productPrice,productDesc,productStatus) " +
            "values(#{productNum},#{productName},#{cityName},#{departureTime},#{productPrice},#{productDesc},#{productStatus}) ")
    public void save(Product product );

    @Select("select * from product where id = #{id}")
    Product findById(String id) throws Exception;





    /**
     * 删除
     * @param productId
     */
    @Delete("delete from product where id = #{id}")
    void delById(String productId);
}
